package com.shiliuzi.www.common;

import lombok.Data;
import org.springframework.stereotype.Component;

/**
 * 返回前端结果类
 * @param <T>
 */
@Data
@Component
public class Result<T> {
    /**
     * 状态码
     */
    private Integer code;

    /**
     * 错误信息
     */
    private String msg;

    /**
     * 数据
     */
    private T data;

    public static <T> Result<T> success(Integer code,T object) {
        Result<T> result=new Result<>();
        result.code=code;
        result.data=object;
        return result;
    }

    public static <T> Result<T> error(Integer code, String msg) {
        Result<T> result=new Result<>();
        result.code=code;
        result.msg=msg;
        return result;
    }
}
